// File Name : Unit_Test.cpp
// Auther : dream.liuguobiao
// Create Date : 2011-2-19
// Last Edit : 2010-2-19

#define BOOST_TEST_MODULE NODE_TEST
#include <boost/test/included/unit_test.hpp>
#include "Unit_Test.h"

// test the Model =======================================================
BOOST_AUTO_TEST_SUITE( MODEL_TEST )
//BOOST_CHECK(bool);
//BOOST_REQUIRE_EQUAL(a,b); a==b ?
BOOST_AUTO_TEST_CASE( attackerMessage )
{
  using namespace Model;
  model *message = new AttackerMessage();
  BOOST_CHECK(NULL != message);
}

BOOST_AUTO_TEST_CASE( attackTargetMessage )
{
  using namespace Model;
  model *message = new AttackTargetMessage();
  BOOST_CHECK(NULL != message);
}


BOOST_AUTO_TEST_CASE( systemSettingMessage )
{
  using namespace Model;
  model *message = new SystemSettingMessage();
  BOOST_CHECK(NULL != message);
}

BOOST_AUTO_TEST_CASE( modelManager )
{
  using namespace Controller;
  using namespace Model;

  Broadcast *broadcast = new Broadcast("test");
  broadcast->SetBoolData(true);
  StubModel *message = new StubModel ();
  ModelManager *modelManager = new ModelManager();
  BOOST_CHECK( 0 == modelManager->ModelNum() );
  modelManager->AddModel(message);
  BOOST_CHECK( 1 == modelManager->ModelNum() );

  modelManager->ReceiveBroadcast(broadcast);
  BOOST_CHECK( !message->NullBroadcast() );
  message->SendBroadcast(broadcast);
  BOOST_CHECK( !message->NullBroadcast() );
}

BOOST_AUTO_TEST_SUITE_END ()


// test the Controller =================================================
BOOST_AUTO_TEST_SUITE( CONTROLLER_TEST )

BOOST_AUTO_TEST_CASE( broadcast )
{
  using namespace Controller;
  std::string stringData("new string data");
  Broadcast *broadcast = new Broadcast("null");
  broadcast->SetBoolData(true);
  broadcast->SetStringData(stringData);
  broadcast->SetIntData(1);
  broadcast->SetDoubleData(2.0);
  Broadcast copyBroadcast = *broadcast;
  BOOST_CHECK( true == copyBroadcast.GetBoolData() );
  BOOST_CHECK( stringData == copyBroadcast.GetStringData() );
  BOOST_CHECK( 1 == copyBroadcast.GetIntData() );
  BOOST_CHECK( 2.0 == copyBroadcast.GetDoubleData() );
  
// only friend class can use the function SetAttribute()
/*
  copyBroadcast.SetAttribute(BROADCAST_READ_ONLY);
  broadcast->SetBoolData(false);
  BOOST_CHECK( true == copyBroadcast.GetBoolData() );
  copyBroadcast.SetAttribute(BROADCAST_READ_WRITE);
  broadcast->SetBoolData(false);
  BOOST_CHECK( false == copyBroadcast.GetBoolData() );
*/
}

BOOST_AUTO_TEST_SUITE_END ()


// test the view =======================================================
BOOST_AUTO_TEST_SUITE( VIEW_TEST )

BOOST_AUTO_TEST_CASE( iconButton )
{

}

BOOST_AUTO_TEST_SUITE_END ()
